<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>活动编辑</title>
<style type="text/css">
 /*   body{text-align: center}
  table{font-size: 12px;width: 80%;}
  tr{height: 30px}
  .td{text-align: right} */
</style>
</head>

<link rel="stylesheet"
	href="<%=basePath%>kindeditor/themes/default/default.css" />
<link rel="stylesheet"
	href="<%=basePath%>kindeditor/plugins/code/prettify.css" />
	<link rel="stylesheet"
	href="<%=basePath%>ui/css/edit.css" />
<script type="text/javascript"
	src="<%=basePath%>kindeditor/kindeditor.js"></script>
<script type="text/javascript"
	src="<%=basePath%>kindeditor/lang/zh_CN.js"></script>
<script type="text/javascript"
	src="<%=basePath%>kindeditor/plugins/code/prettify.js"></script>
<script charset="utf-8"
	src="<%=basePath%>kindeditor/kindeditor-myconfig-org.js"></script>
<script type="text/javascript">
$(function(){
	if($("input[name='id']").val()){
		var catagory=$("input[type='radio']:checked").val();
		if(catagory=="pic"){
			$("#picTr").show();
			$("#videoTr").hide();
		}else{
			$("#picTr").hide();
			$("#videoTr").show();
		}
	}else{
		$("#videoTr").hide();
	}
	editor = KindEditor.create('#editer1', {
		  
		  width:'100%',height:'440px',
		 
		   cssPath : '/kindeditor/plugins/code/prettify.css',
		  filterMode:false,
		  
		  uploadJson:'/kindeditor/jsp/upload_json.jsp'
			  ,langType : 'zh_CN',items:KE_simple,resizeType:0
	});
	prettyPrint();
	$("input[name='mesCatagory']").click(function(){
		if($(this).val()=="pic"){
			$("#picTr").show();
			$("#videoTr").hide();
		}else if($(this).val()=="video"){
			$("#picTr").hide();
			$("#videoTr").show();
		}
	});
});
function checkContent() {
	var mesName=$("#mesName").val();
	if(!mesName){
		alert("请输入标题！");
		return false;
	}

	var file=$("#file").val();
	var id=$("#id").val();
	var catagory=$("input[type='radio']:checked").val();
	//debugger;
	if(!id && !file && catagory=='pic'){
		if(!file){
			alert("请上传附件！");
			return false;
		}
	}
	if(catagory=='video'){
		var mesUrl=$("#mesUrl").val();
		if(!mesUrl){
			alert("请输入视频url！");
			return false;
		}
	}
	if(file){
		var type=file.substring(file.lastIndexOf('.')+1,file.length).toLowerCase();
		if(catagory && catagory=="pic"){
			if(type!='jpg' && type !='gif' && type !='png' && type!='bmp'){
				alert("请上传图片格式附件");
				return false;
			}
		}
	}
		var content = editor.text();
	if (editor.isEmpty()) {
		alert("请输入内容！");
		return false;
	}
	if (content.length > 20000) {
		alert("内容长度不能超过20000字！");
		return false;
	}
	var content2 = editor.html();
	$("#editer1").val(content2);
	return true;
}
</script>
<body>
				<form action="${basePath}newsActivity/saveFile.html" id="myform"
					method="post" onsubmit="return checkContent()"
					enctype="multipart/form-data">
					<input type="hidden" name="porCode" value="${porCode}"> <input
						type="hidden" name="id"  id="id" value="${entity.id}"> <input
						type="hidden" name="type" value="${type}" >
					<table  cellspacing="0" cellpadding="0" border="0"  class="addclass">
					 <tr>
	  		    <td colspan="2><div class="nav"><%@ include file="/common/nav.jsp"%></div></tr>
	  		  </tr>
						<tr>
							<td width="20%" class="trLeft">标题：</td>
							<td><input type="text" name="mesName" id="mesName"
								value="${entity.mesName}" maxlength="60"></td>
						</tr>
						<tr>
							<td width="20%" class="trLeft">类型：</td>
							<td><c:if test="${not empty entity.id }">
									<input type="radio" name="mesCatagory" value="pic" class="otherInput"
										<c:if test="${entity.mesCatagory=='pic' }"> checked="checked" </c:if>>图片
				 <input type="radio" name="mesCatagory" value="video" class="otherInput"
										<c:if test="${entity.mesCatagory !='pic' }"> checked="checked" </c:if>>视频
				</c:if> <c:if test="${ empty entity.id }">
									<input type="radio" name="mesCatagory" value="pic"  class="otherInput"
										checked="checked">图片
				 <input type="radio" name="mesCatagory" value="video" class="otherInput" maxlength="100">视频
				</c:if></td>
						</tr>
						<tr>
							<td width="20%" class="trLeft">作者：</td>
							<td><input type="text" name="mesAuthor"
								value="${entity.mesAuthor}" maxlength="20"></td>
						</tr>
						<tr id="picTr">
							<td width="20%" class="trLeft" valign="top">附件：</td>
							<td><input type="file" name="file" id="file"  class="fileInput"><br>
								<input name="mesAccessory" type="hidden"
								value="${entity.mesAccessory }"> <c:if
									test="${not empty mescatagory && mesCatagory=='video' }">
									<embed align=center src="<%=uiPath %>${entity.mesAccessory }"
										type=application/x-shockwave-flash wmode="transparent"
										quality="high">
									</embed>
								</c:if> <c:if test="${not empty entity.mesAccessory}">
									<img src="<%=uiPath %>${entity.mesAccessory}" width="200"
										height="132">
								</c:if></td>
						</tr>
						<tr id="videoTr" >
							<td width="20%" class="trLeft">视频URL：</td>
							<td><input type="text" name="mesUrl" id="mesUrl"
								value="${entity.mesUrl}" maxlength="150"></td>
						</tr>
						<tr>
							<td valign="top" class="trLeft">内容：</td>
							<td><textarea id="editer1" name="mesContent"
									style="width:700px;height:300px;">${entity.mesContent }</textarea></td>
						</tr>
						<tr>
							<td colspan="2" style="text-align: center"><input class="button"
								type="submit" value="提交" id="save"></td>
							<!-- onclick="save()" -->
						</tr>
					</table>
				</form>

</body>
</html>
